import request from '@/utils/request.js'
// import store from '@/store'

export const login = data => request({
  method: 'POST',
  url: 'v1_0/authorizations',
  data
})

export const getSmsCode = mobile => {
  return request({
    method: 'GET',
    url: `/v1_0/sms/codes/${mobile}`
  })
}

export const getUserInfo = () => request({
  method: 'GET',
  url: '/v1_0/user'
  // headers: {
  //   Authorization: `Bearer ${store.state.user.token}`
  // }
})

export const addFollow = userId => request({
  method: 'POST',
  url: '/v1_0/user/followings',
  data: {
    target: userId
  }
})
// export const addFollow = userId => {
//   return request({
//     method: 'POST',
//     url: '/v1_0/user/followings',
//     data: {
//       target: userId
//     }
//   })
// }

export const deleteFollow = userId => request({
  method: 'DELETE',
  url: `v1_0/user/followings/${userId}`
})

export const getUserMessage = () => request({
  method: 'GET',
  url: '/v1_0/user/profile'
})

export const setUserMessage = data => request({
  method: 'PATCH',
  url: '/v1_0/user/profile',
  data
})

export const setUserPhoto = data => request({
  method: 'PATCH',
  url: '/v1_0/user/photo',
  data
})
